#include <iomanip>
#include <iostream>
using std::cout;
using std::endl;

#include "Account.h"
#include "SavingsAccount.h"
#include "CheckingAccount.h"

int main(int argc, const char *argv[])
{
    Account account1 (50.0);
    SavingsAccount account2 (25.0, 0.03);
    CheckingAccount account3 (80.0, 1.0);

    cout << std::fixed << std::setprecision (2);

    cout << "account1 balance: $" << account1.getBalance () << endl;
    cout << "account2 balance: $" << account2.getBalance () << endl;
    cout << "account3 balance: $" << account3.getBalance () << endl;

    cout << "\nAttempting to debit $25.0 from account1." << endl;
    account1.debit (25.0);
    cout << "\nAttempting to debit $30.0 from account2." << endl;
    account2.debit (30.0);
    cout << "\bAttempting to debit $40.0 from account3." << endl;
    account3.debit (40.0);
    
    cout << "\naccount1 balance: $" << account1.getBalance () << endl;
    cout << "account2 balance: $" << account2.getBalance () << endl;
    cout << "account3 balance: $" << account3.getBalance () << endl;

    cout << "\nCrediting $40.0 to account1." << endl;
    account1.credit (40.0);
    cout << "\nCrediting $65.0 to account2." << endl;
    account2.credit (65.0);
    cout << "\nCrediting $20.0 to account3." << endl;
    account3.credit (20.0);
    
    cout << "\naccount1 balance: $" << account1.getBalance () << endl;
    cout << "account2 balance: $" << account2.getBalance () << endl;
    cout << "account3 balance: $" << account3.getBalance () << endl;

    double interestEarned = account2.calculateInterest ();
    cout << "\nAdding $" << interestEarned << " interest to account2."
         << endl;
    account2.credit (interestEarned);
    cout << "\nNew account2 balance: $" << account2.getBalance () << endl;

    return 0;
}
